import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    {
      path: '/',
      name: 'layout',
      redirect: '/home',
      component: () => import('@/views/Layout.vue'),
      children: [
        {
          path: '/home',
          name: 'home',
          component: () => import('@/views/Home.vue')
          // meta: {
          //   keepAlive: true // 需要被缓存
          // }
        },
        {
          path: '/find',
          name: 'find',
          component: () => import('@/views/Find.vue')
          // meta: {
          //   keepAlive: true // 需要被缓存
          // }
        },
        {
          path: '/news',
          name: 'news',
          component: () => import('@/views/News.vue')
        },
        {
          path: '/my',
          name: 'my',
          component: () => import('@/views/My.vue')
        }
      ]
    },
    {
      path: '/detail/:id',
      name: 'detail',
      component: () => import('@/views/Detail.vue')
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/Login.vue')
    },
    {
      path: '/register',
      name: 'register',
      component: () => import('@/views/Register.vue')
    },
    {
      path: '/city',
      name: 'city',
      component: () => import('@/views/City.vue')
    }
  ]
})

export default router
